import Vue from "vue";
import VueRouter from "vue-router";
import Layout from '../layout/default'


// 点击没问题 如果在这个点击页面 在点击一次router-link 就会报这个错 但是不影响功能
// 去你引用vue-router的页面添加一段代码
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter);

// const routes = [
//   {
//     path: "/",
//     component: Layout,
//     redirect: '/startup',
//     children: [
//       {
//         path: "/home",
//         name: "Home",
//         component: () => import('../views/home'),
//         hidden: true
//       },
//       {
//         path: "/store",
//         name: "Store",
//         component: () => import('../views/store'),
//         hidden: true
//       },
//       {
//         path: "/message",
//         name: "Message",
//         component: () => import('../views/message'),
//         hidden: true
//       },
//       {
//         path: "/user",
//         name: "User",
//         component: () => import('../views/user'),
//         hidden: true
//       },
//       {
//         path: "/hospital/:id",
//         name: "Hospital",
//         component: () => import('../views/hospital'),
//         hidden: true
//       },
//       {
//         path: "/user/setting",
//         name: "Setting",
//         component: () => import('../views/user/setting.vue'),
//         hidden: true
//       },
//       {
//         path: "/user/feedback",
//         name: "Feedback",
//         component: () => import('../views/user/feedback.vue'),
//         hidden: true
//       },
//       {
//         path: "/user/about",
//         name: "About",
//         component: () => import('../views/user/about.vue'),
//         hidden: true
//       },
//       {
//         path: "/user/chat",
//         name: "Chat",
//         component: () => import('../views/user/chat.vue'),
//         hidden: true
//       },
//       {
//         path: "/user/help",
//         name: "Help",
//         component: () => import('../views/user/help.vue'),
//         hidden: true
//       },
//       {
//         path: "/user/invite",
//         name: "Invite",
//         component: () => import('../views/user/invite.vue'),
//         hidden: true
//       }
//     ]
//   },
//   {
//     path: "/startup",
//     name: "Startup",
//     component: () => import('../views/startup')
//   },
//   {
//     path: "/login",
//     name: "Login",
//     component: () => import('../views/login'),
//     hidden: true
//   },
//   {
//     path: "*",
//     component: () => import('../views/404'),
//     hidden: true
//   }
// ];

const routes = [
  {
    path: "/",
    component: Layout,
    redirect: '/startup',
    children: [
      {
        path: "/home",
        name: "Home",
        component: () => import('../views/home'),
        hidden: true
      },
      {
        path: "/store",
        name: "Store",
        component: () => import('../views/store'),
        hidden: true
      },
      {
        path: "/message",
        name: "Message",
        component: () => import('../views/message'),
        hidden: true
      },
      {
        path: "/hospital/:id",
        name: "Hospital",
        component: () => import('../views/hospital'),
        hidden: true
      },
      {
        path: "/user",
        component: () => import('../layout/user.vue'),
        hidden: true,
        children: [
          {
            path: "",
            name: "User",
            component: () => import('../views/user/index.vue'),
          },
          {
            path: "setting",
            name: "Setting",
            component: () => import('../views/user/setting.vue'),
            hidden: true
          },
          {
            path: "feedback",
            name: "Feedback",
            component: () => import('../views/user/feedback.vue'),
            hidden: true
          },
          {
            path: "about",
            name: "About",
            component: () => import('../views/user/about.vue'),
            hidden: true
          },
          {
            path: "chat",
            name: "Chat",
            component: () => import('../views/user/chat.vue'),
            hidden: true
          },
          {
            path: "help",
            name: "Help",
            component: () => import('../views/user/help.vue'),
            hidden: true
          },
          {
            path: "invite",
            name: "Invite",
            component: () => import('../views/user/invite.vue'),
            hidden: true
          }
        ]
      },
    ]
  },
  {
    path: "/startup",
    name: "Startup",
    component: () => import('../views/startup')
  },
  {
    path: "/login",
    name: "Login",
    component: () => import('../views/login'),
    hidden: true
  },
  {
    path: "*",
    component: () => import('../views/404'),
    hidden: true
  }
];

const router = new VueRouter({
  mode: 'hash', // history
  routes
});

export default router;
